package com.googlecode.jvmpart;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.googlecode.jvmpart.support.LocalProcessManager;

public class ProcessManagerFactory {
	private static final Log logger = LogFactory.getLog(ProcessManagerFactory.class);
	private static ProcessManager processManager;
	public static ProcessManager getInstance() {
		if(processManager==null) {
			String clazz = System.getProperty(ProcessManager.class.getCanonicalName());
			logger.debug("Process Manager:"+clazz);
			if(clazz==null) {
				processManager = new LocalProcessManager();
			} else {
				try {
					processManager = (ProcessManager)Class.forName(clazz).newInstance();
				} catch (Exception e) {
					logger.warn(e, e);
					processManager = new LocalProcessManager();
				}
			}
		} 
		return processManager;
	}
}
